<?php
class LatestPosts extends CWidget {
	public $posts;
	
	public function init() {
		$criteria = new CDbCriteria;
		$criteria->order = 'postId DESC';
		$criteria->limit = 10;
		$this->posts = Posts::model()->findAll($criteria);
	}
	
	public function run() {
		$this->renderContent();
	}

	public function renderContent($return = false) {
		return $this->render('latest-posts', array('posts' => $this->posts), $return);
	}
}